home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 241_01 / weknow.ci < prev   
Encoding:
Text File  |  1987-08-29  |  2.3 KB  |  80 lines

  1. /*
  2. HEADER:         CUG241;
  3. TITLE:          Inference Engine for Expert System;
  4. DATE:           12/30/85;
  5. VERSION:
  6. DESCRIPTION:   "Source code for inference engine for an Expert System.";
  7. KEYWORDS:       Artificial Intelligence, expert systems, inference engine;
  8. SYSTEM:         MS-DOS or UNIX System V;
  9. FILENAME:       WEKNOW.C;
  10. WARNINGS:      "User-supported, non-commercial"
  11. AUTHORS:        George Hageman; 
  12. COMPILERS:      Microsoft C V3.00 or UNIX System V Portable C Compiler;
  13. REFERENCES:     ;
  14. ENDREF
  15. */
  16.  
  17. /*****************************************************************
  18. **                                **
  19. **      Inference -- (C) Copyright 1985 George Hageman    **
  20. **                                **
  21. **        user-supported software:                **
  22. **                                **
  23. **            George Hageman                **
  24. **            P.O. Box 11234                **
  25. **            Boulder, Colorado 80302            **
  26. **                                **
  27. *****************************************************************/
  28.  
  29. /*****************************************************************
  30. **    
  31. **    weKnow(antecedent,&predicate) 
  32. **
  33. **    routines searches both knownTrue and knownFalse
  34. **    stacks to determine whether the antecedent is known.
  35. **
  36. **    the return value of the routine is TRUE if known and FALSE otherwise
  37. **
  38. **    the predicate is set to the "true" value of the antecedent according
  39. **    to whether its phase is TRUE or FALSE and its .flag indicator.
  40. **
  41. *****************************************************************/
  42.  
  43. #include "expert.h"
  44. #include "inference.h"
  45.  
  46. int    weKnow(antecedent,p_value)
  47.     int antecedent,*p_value ;
  48. {
  49. if(known(antecedent,knownTrue,numTrue) == TRUE )
  50.     switch(ruleBuff[antecedent].flag)
  51.         {
  52.         case STRING_TRUE:
  53.         case STRING_TRUE_HYP:
  54.         case ROUTINE_TRUE:
  55.         case ROUTINE_TRUE_HYP:
  56.             *p_value = TRUE ;
  57.             return(TRUE)  ;
  58.         case STRING_FALSE:
  59.         case ROUTINE_FALSE :
  60.             *p_value = FALSE ;
  61.             return(TRUE) ;
  62.         }
  63. if(known(antecedent,knownFalse,numFalse) == TRUE )
  64.     switch(ruleBuff[antecedent].flag)
  65.         {
  66.         case STRING_TRUE:
  67.         case STRING_TRUE_HYP:
  68.         case ROUTINE_TRUE:
  69.         case ROUTINE_TRUE_HYP :
  70.             *p_value = FALSE ;
  71.             return(TRUE) ;
  72.         case STRING_FALSE:
  73.         case ROUTINE_FALSE:
  74.             *p_value = TRUE ;
  75.             return(TRUE)  ;
  76.         }
  77. return(FALSE) ;
  78. }
  79.  
  80.